﻿//赋值部门下拉框
function getDeptSelect() {
    layui.use('form', function () {
        var form = layui.form;
        form.render();
        $("#userDep").next().remove();
        $('#userDep').select2({});
    });
    $.ajax({
        url: "../Basis/getDeptList",
        type: "get",
        data: { "page": "1", "limit": "1000" },
        success: function (Data) {  
            var reData = Data.data;
            $("#userDep").append("<option>           </option>");
            for (var i = 0; i < reData.length; i++) {
                $("#userDep").append("<option value='" + reData[i].depName + "'>" + reData[i].depName + "</option>");
            }
        }
    })
}

//赋值部门列表
function getDeptList() {
    var deptCode = $("#deptCode").val();
    var deptName = $("#deptName").val();
    layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
        var laydate = layui.laydate //日期
            , laypage = layui.laypage //分页
            , layer = layui.layer //弹层
            , table = layui.table //表格
            , carousel = layui.carousel //轮播
            , upload = layui.upload //上传
            , element = layui.element //元素操作
            , slider = layui.slider //滑块


        //给table赋值
        table.render({
            elem: '#deptList'
            , height: 380
            //, width: 1030
            , url: '../Basis/getDeptList?deptName=' + deptName + '&deptCode=' + deptCode + '' //数据接口
            , title: '部门表'
            , page: true //开启分页
            , even: true
            , limits: [20, 50, 80, 100]
            , toolbar: true //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , defaultToolbar: ['print', 'exports']
            , cols: [[ //表头
                { type: 'checkbox', fixed: 'left' }
                , { field: 'depCode', title: '部门编号', width: 110, sort: true, fixed: 'left' }
                , { field: 'depName', title: '部门名称', width: 110 }
                , { field: 'accCode', title: '所属账套', width: 110 }
                , { field: 'isAccName', title: '同步数据', width: 110, sort: true }
                , { field: 'createTime', title: '创建时间', width: 180 }
                , { field: 'createUser', title: '创建人员', width: 150 }
            ]]
        });
    });
}
